<template>
  <div id="bottom">
    <van-tabbar v-model="flag">
      <van-tabbar-item to="/home" icon="home-o" style="background: lightpink"
        >首页</van-tabbar-item
      >
      <van-tabbar-item @click="to" style="background: lightpink"
        ><img :src="require('../assets/添加.png')" alt="" class="add"
      /></van-tabbar-item>
      <van-tabbar-item
        @click="if_senior"
        icon="user-o"
        style="background: lightpink"
        >我的</van-tabbar-item
      >
    </van-tabbar>
  </div>
</template>

<script>
import axios from "axios";
import { Toast } from "vant";

export default {
  props: { active: Number },
  data() {
    return {
      users: [],
      flag: this.active,
    };
  },
  methods: {
    to() {
      axios.get("/api/qbs/api/userall.php").then((response) => {
        this.users = response.data.data;
        // console.log(response.data.data.state);
        let state = localStorage.getItem("login_user_state");
        console.log(state);
        if (state == 1) {
          this.$router.push("/addexp");
        } else {
          Toast.fail("请先申请成为前辈！");
        }
      });
    },
    if_senior() {
      axios.get("/api/qbs/api/userall.php").then((response) => {
        this.users = response.data.data;
        // console.log(response.data.data.state);
        let state = localStorage.getItem("login_user_state");
        console.log(state);
        if (state == 1) {
          this.$router.push("/myseniorProfile");
        } else {
          this.$router.push("/myuserProfile");
        }
      });
    },
  },
};
</script>

<style>
.van-tabbar-item--active {
  color: aliceblue;
}
.add {
  width: 60px;
  height: 60px;
}
</style>
.van-tabbar-item--active {
  color: aliceblue;
}
.add {
  width: 60px;
  height: 60px;
}
</style>